MK_MODE ?= aa
$(info ----------use mode $(MK_MODE))
ifeq ($(MK_MODE), aa)
	LIB = -L. -lcall_a -ltest_a
endif

ifeq ($(MK_MODE), sa)
	LIB = -L. -lcall_s -ltest_a
endif

ifeq ($(MK_MODE), as)
	LIB = -L. -lcall_a -ltest_s
endif

ifeq ($(MK_MODE), ss)
	LIB = -L. -lcall_s -ltest_s
endif

all:libtest_a.a libtest_s.so libcall_a.a libcall_s.so
	@echo -e "\n----------a.out link"
	gcc main.c -L. $(LIB)


libtest_a.a:
	@echo -e "\n----------static libtest"
	gcc -c -o test.o test.c
	ar -rc libtest_a.a test.o

libtest_s.so:
	@echo -e "\n----------shared libtest"
	gcc -c -fPIC -o test.o test.c
	gcc -shared -fPIC -o libtest_s.so test.o 

libcall_a.a:
	@echo -e "\n----------static libcall"
	gcc -c -o call.o call.c
	ar -rc libcall_a.a call.o

libcall_s.so:
	@echo -e "\n----------shared libcall"
	gcc -c -fPIC -o call.o call.c
	gcc -shared -fPIC -o libcall_s.so call.o 

clean:
	rm -f a.out *.o *.a *.so
